//
//  UIView+frame.m
//  BuDeJie
//
//  Created by haoran on 14/4/1.
//  Copyright © 2014年 xuhaoran. All rights reserved.
//

#import "UIView+frame.h"

@implementation UIView (frame)

-(CGFloat)xhr_x{
    
    return self.frame.origin.x;
}
-(CGFloat)xhr_y{

    return self.frame.origin.y;
}
-(CGFloat)xhr_width{
    
    return self.bounds.size.width;
}
-(CGFloat)xhr_height{
    return self.bounds.size.height;
}
-(CGFloat)xhr_CenterX{
    return self.center.x;
}
-(CGFloat)xhr_CenterY{
    return self.center.y;
}


-(void)setXhr_x:(CGFloat)xhr_x{
    CGRect frame = self.frame;
    frame.origin.x = xhr_x;
    self.frame = frame;
}

-(void)setXhr_y:(CGFloat)xhr_y{
    CGRect frame = self.frame;
    frame.origin.y = xhr_y;
    self.frame = frame;
    
}

-(void)setXhr_width:(CGFloat)xhr_width{
    CGRect bounds = self.frame;
    bounds.size.width = xhr_width;
    self.frame = bounds;

}

-(void)setXhr_height:(CGFloat)xhr_height{
    CGRect bounds = self.frame;
    bounds.size.height = xhr_height;
    self.frame = bounds;
}

-(void)setXhr_CenterX:(CGFloat)xhr_CenterX{
    CGPoint center = self.center;
    center.x = xhr_CenterX;
    self.center = center;
}

-(void)setXhr_CenterY:(CGFloat)xhr_CenterY{
    CGPoint center = self.center;
    center.y = xhr_CenterY;
    self.center = center;

}


/** 快速从xib创建View **/
+(instancetype)xhr_viewFromXib{

    return [[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil].firstObject;
}

@end
